<?php

namespace app\common\model\mysql;

class Admin extends BaseModel
{
    public function role()
    {
        return $this->hasOne(Role::class,'id','role_id');
    }

    public function getLastLoginTimeAttr($value){
        return date('Y-m-d H:i:s', $value);
    }

    public function getRoleByUserId($where,$field,$field2)
    {
        try {
            $result = $this->field($field)->where($where)->with(['role'=>function($query) use($field2){
                $query->field($field2);
            }])->select();
        }catch (\Exception $e){
            return false;

        }
        return $result;
    }

    public function getRoleIdById($ids){
        return $this->where('role_id','in',$ids)->column('role_id');
    }



}